package com.mspbots.core.bot.controller;

import com.mspbots.core.AbstractBaseController;
import com.mspbots.core.bot.model.InitBotDTO;
import com.mspbots.core.bot.model.SystemBot;
import com.mspbots.core.bot.model.SystemBotDTO;
import com.mspbots.core.bot.service.SystemBotService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;

/**
 * com.mspbots.core.bot.controller.SystemBotController
 *
 * @author Jason
 * @date 2019/12/19
 **/
@RestController
@RequestMapping("system-bot")
public class SystemBotController extends AbstractBaseController<SystemBot, SystemBotService> {

    @PostMapping("save")
    public Callable insert(@RequestBody SystemBotDTO entity) {
        return () -> service.insertOrUpdate(entity);
    }

    @PostMapping("init-tenant")
    public Callable initTenant(@RequestBody InitBotDTO initBotDTO) {
        return () -> service.initTenant(initBotDTO.getSystemBotIds(), initBotDTO.getTenantId());

    }

}
